import SwiftUI

struct WithAnimationView : View {
    // Animatable attributes
    @State var offsetY: CGFloat = 0 // Position related
    @State var d: CGFloat = 100     // Size related
    
    var body: some View {
        VStack(spacing: 30) {
            Text("With Animation")
                .font(.largeTitle)
            
            Text("Parts of animation")
                .font(.title)
                .foregroundColor(.gray)
            
            Text("....")
            
            
            Circle()
                .foregroundColor(.orange)
                .frame(width: d, height: d)
                .offset(x: 0, y: offsetY)
                .animation(.easeIn/*Animation curve*/, value: d)
                .animation(.easeOut, value: offsetY)
            
            Spacer()
            
            Button(action: {
                // ?:
                offsetY = offsetY == 500 ? 0 : 500
                d = d == 100 ? 10 : 100
            }, label: {
                Text("Move")
                    .font(.title)
                    .padding(.bottom, 50)
            })
            
        }
    }
}
